angular.module('${menuCode}')
.controller("${widgetCode}Ctrl",function($scope,AppKit){
	$scope.loadData = function(){
		var url = '/portal/resource?MobileForumDataProvider&actionType=getForumInformation&fpmId='+$scope.currentInfoId;
		var promise = AppKit.getJsonApi(url);
		promise.success(function(rspJson){
			$scope.id = rspJson.id;
			$scope.title = rspJson.title;
			$scope.content = rspJson.content;
			$scope.comments = rspJson.comments;
			$scope.floor = rspJson.floor;
			$scope.reportNum = rspJson.reportNum;
		});
		
		$scope.info = {"fpmId":$scope.currentInfoId,"replyFloor":"","friContent":""};
	}
	
	$scope.loadData();
	
	$scope.doPostReply = function(){
		var url = "/portal/resource?ForumPost&actionType=mobileCreateRepleceForumInfo"
		AppKit.postJsonApi(url,$scope.info).then(function(response){
			if ("success" == response.data){
				$scope.loadData();
				$scope.info.friContent = "";
				
				AppKit.successPopup();				
			}else{
				AppKit.errorPopup();
			}
		});
	}
	
	$scope.followInfo = {"fpmId":$scope.currentInfoId};
	$scope.doFollow = function(){
		var url = "/portal/resource?ForumPost&actionType=mobileCreateForumFavorite"
		AppKit.postJsonApi(url,$scope.followInfo).then(function(response){
			if ("success" == response.data){
				AppKit.successPopup();				
			}else{
				AppKit.errorPopup();
			}
		});
	}
	
	var url = '/portal/resource?MobileForumDataProvider&actionType=mobileIsGuest';
	var promise = AppKit.getJsonApi(url);
	promise.success(function(rspJson){
		$scope.isGuest = rspJson.isGuest;
	});
});